import java.util.HashMap;
import java.util.Map.Entry;


  public class LampGrid {
    public int mostLit(String[] initial, int K) {
      HashMap<String, Integer> map = new HashMap<String, Integer>();
      for (String str: initial) {
        if (!map.containsKey(str))
          map.put(str, 1);
        else map.put(str, map.get(str)+1);
        }
  
      int count = 0; //this should be outside of the for loop, beautiful.
      for(Entry<String, Integer> entry: map.entrySet()){
          int num_0 = 0;
          for(char c: entry.getKey().toCharArray()) {
            if(c == '0')
              num_0++;
          }
          if (K >= num_0 && (K-num_0)%2 == 0)
            count = Math.max(entry.getValue(), count);
        }
      return count;
    }
  }